package com.xiaobai.units;

import com.arronlong.httpclientutil.builder.HCB;
import com.arronlong.httpclientutil.common.SSLs;
import com.arronlong.httpclientutil.exception.HttpProcessException;

public class HttpPool {

    private static HCB hcb;

    private static void initPool(){

        try {
            hcb = HCB.custom()
                    .timeout(8000) //超时
                    .pool(50, 10) //启用连接池，每个路由最大创建10个链接，总连接数限制为100个
                    .sslpv(SSLs.SSLProtocolVersion.TLSv1_2)
                    .ssl()        //https，支持自定义ssl证书路径和密码，ssl(String keyStorePath, String keyStorepass)
                    .retry(1)        //重试1次
                    ;
        } catch (HttpProcessException e) {
            e.printStackTrace();
        }
    }

    static {
        initPool();//初始化
    }

    public static HCB getHcb(){
        return hcb;
    }

}
